package com.stars.system.monitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.stars.system.monitor.domain.Direct;
import com.stars.system.monitor.service.IDirectService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * directController
 * 
 * @author shuaibizhe
 * @date 2022-08-07
 */
@RestController
@RequestMapping("/monitor/direct")
public class DirectController extends BaseController
{
    @Autowired
    private IDirectService DirectService;

    /**
     * 查询direct列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:list')")
    @GetMapping("/list")
    public AjaxResult list(Direct Direct)
    {
        List<Direct> list = DirectService.selectDirectList(Direct);
        return AjaxResult.success(list);
    }

    /**
     * 获取direct信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:list')")
    @GetMapping("/info")
    public AjaxResult info(Direct Direct)
    {
        boolean boo = DirectService.selectDirectInfo(Direct);
        return AjaxResult.success(boo);
    }

    /**
     * 导出direct列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:export')")
    @Log(title = "direct", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Direct Direct)
    {
        List<Direct> list = DirectService.selectDirectList(Direct);
        ExcelUtil<Direct> util = new ExcelUtil<Direct>(Direct.class);
        util.exportExcel(response, list, "direct数据");
    }

    /**
     * 获取direct详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:query')")
    @GetMapping(value = "/{directId}")
    public AjaxResult getInfo(@PathVariable("directId") Long directId)
    {
        return AjaxResult.success(DirectService.selectDirectByDirectId(directId));
    }

    /**
     * 新增direct
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:add')")
    @Log(title = "direct", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Direct Direct)
    {
        return toAjax(DirectService.insertDirect(Direct));
    }

    /**
     * 修改direct
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:edit')")
    @Log(title = "direct", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Direct Direct)
    {
        return toAjax(DirectService.updateDirect(Direct));
    }

    /**
     * 删除direct
     */
    @PreAuthorize("@ss.hasPermi('monitor:direct:remove')")
    @Log(title = "direct", businessType = BusinessType.DELETE)
	@DeleteMapping("/{directIds}")
    public AjaxResult remove(@PathVariable Long[] directIds)
    {
        return toAjax(DirectService.deleteDirectByDirectIds(directIds));
    }
}
